<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.knowledge.model.Knowledge" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<%String title="添加新知识";
	String userId = (String)request.getAttribute("userId");
	String knowledgeId = (String)request.getAttribute("knowledgeId");
	Knowledge knowledge = (Knowledge)request.getAttribute("knowledge");
	if (knowledge == null)
		knowledge = new Knowledge();
	if(knowledgeId!=null)
		title="编辑知识";
	 %>
	<title><%=title%></title>
    <!-- css --> 
	<link rel="stylesheet" type="text/css" href="css/fonts-min.css" />
	<link rel="stylesheet" type="text/css" href="css/skins/sam/simpleeditor.css" />
    <link href="css/layout.css" rel="stylesheet" type="text/css" media="all">
	<link href="css/blog.css" rel="stylesheet" type="text/css" media="all">
	<link href="css/ui.css" rel="stylesheet">
	<link href="css/header.css" rel="stylesheet" type="text/css" />
	<link href="css/base.css" rel="stylesheet" type="text/css" media="all" />
	<style type="text/css">
		input,label,span,select,h2,p{text-align:left}
		.tips{text-align:center}
	</style>
	<!-- js --> 
	<script type="text/javascript" src="js/yahoo-dom-event.js"></script>
	<script type="text/javascript" src="js/element-beta-min.js"></script>
	<script type="text/javascript" src="js/container_core-min.js"></script>
	<script type="text/javascript" src="js/simpleeditor-min.js"></script> 
  	
  	
    <body id="blogeditor" class="blogeditor">
    <jsp:include page="header.jsp"></jsp:include>
    	<center>
		<div id="container">
			<div id="opi" class="page-wrapper clearfix">
        		<div class="full-page-holder">
        			<div class="full-page clearfix">
        				<div id="content">
        					<div class="page-title post"><h2><%=title%></h2></div>
		  					<div id="oak" class="gray">	
								<form action="updateknowledge.action" id="editorForm" method="post">
									<div id="single-column" style="position: relative;">
										<div class="editorHolder">
											<p>
												<label class="label" for="title">标题：</label>
												<input name="title" id="title" class="input-text" tabindex="1" value="<%=knowledge.getTitle()%>" type="text">
												<span class="altbox saving" id="auto_save_msg" style="display: none;">自动保存中……</span>
											</p>
											<p class="blog_body">
												<textarea id="editor" name="content" rows="20" cols="75"><%=knowledge.getContent()%></textarea>
											</p>
											<p class="bd">
												<label class="label">提醒频率设置：</label>
												<select name="categoryId" id="categoryId" class="select" onchange="changeFrequency(this.value)">
                                                	<option value="0">默认设置</option>
                                                    <option value="1">自定义设置</option>
                                                </select>
                                                <input name="frequency" id="frequency" class="input-text" readonly="readonly" value="1,3,7,15,30" type="text" />&nbsp;&nbsp; 输入提醒天数并以逗号分隔
								 			</p>
											<p id="permissionBox" class="permission bd"> 谁能浏览这篇知识：
												<select name="accesscontrol" tabindex="3" id="blogControl" class="select">
                            						<option value="0">我的好友</option>
													<option value="1">只有我自己</option>
												</select>
											</p>
											<p id="upFile">
												<input name="userId" value="<%=userId%>" type="hidden">
												<input name="knowledgeId" value="<%=knowledgeId%>" type="hidden">
											</p>
											<p class="actions align-left">
												<input value="添加" class="input-submit" tabindex="4" type="button" onClick="post()">
											</p>
						
					</div>
					
						<div id="blog-releative">
	    
	    					<div class="add">
		   						<h3>添加知识相关标签</h3>
								<p class="tips">键入标签并以逗号分隔</p>
								<input name="labels" class="input-text" maxlength="100" type="text">
						</div>
	    
    
						<div class="added">
							<h3>与知识有关的标签</h3>
							<div id="relatives" class="list">
							</div>
						</div>
    
   			 </div>
				
		</div>
		</form>
<script>
    var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
    
    var myConfig = {
        height: '300px',
        width: '600px',
        focusAtStart: true
    };
    var myEditor = new YAHOO.widget.SimpleEditor('editor', myConfig);
    myEditor.render();
function changeFrequency(o){
	var el = document.getElementById("frequency");
	switch(o){
	case "0":el.readOnly=true;el.value="1,3,7,15,30";break;
	case "1":el.readOnly=false;el.value="";	
	}
}
function post(){
	myEditor.saveHTML();
	document.getElementById("editor").value = myEditor.get('textarea').value;
	document.forms[1].submit();
}
</script>

	</div>
	</div>
    </div>
    </div>
    </div>
    </div>
</center>
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>